package org.example.shardUpload;

import org.example.nettyrpc.common.IpPortTuple;
import org.junit.Test;

import java.io.IOException;

public class ShardUploadTest {
    private void serverBoot() throws InterruptedException {
        UploadServer uploadServer = new UploadServer(new IpPortTuple("127.0.0.1", 5466));
        uploadServer.bootHostAndGuestRpc();
    }

    private void clientBoot() throws IOException, InterruptedException {
        UploadClient uploadServer = new UploadClient(new IpPortTuple("127.0.0.1", 5466));
        uploadServer.bootHostAndGuestRpc();
        uploadServer.uploadFileByName("./src/main/java/org/example/shardUpload/data.txt");
    }

    @Test
    public void test001() throws InterruptedException {
        new Thread(() -> {
            try {
                serverBoot();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }).start();

        Thread t = new Thread(() -> {
            try {
                clientBoot();
            } catch (IOException | InterruptedException e) {
                throw new RuntimeException(e);
            }
        });
        t.start();
        t.join();
    }
}
